package com.b1.taskmanager.start;
import com.b1.taskmanager.api.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Scanner;

/**
 * класс для работы в консоли
 * 
 */
public class Start_console 
{
    public static void dialog() throws IOException, ParseException 
    {
        ContactList r = new ContactList();
        TaskList t = new TaskList();
        while(true)
        {
            System.out.println("1 - addContact\t11 - addTask\n2 - showContact\t22-showTask\n3-delContact\t33-delTask\n"
                    + "4-changeContact\t44-changeTask\n5-exit");
            int com = new Scanner(System.in).nextInt();
            switch(com)
            {
                case 1:
                    String[] str = new String[4];
                    System.out.println("Enter name");
                    str[0]=(new Scanner(System.in).nextLine());
                    System.out.println("Enter lastName");
                    str[1]=(new Scanner(System.in).nextLine());
                    System.out.println("Enter middleName");
                    str[2]=(new Scanner(System.in).nextLine());
                    System.out.println("Enter homePhone");
                    str[3]=(new Scanner(System.in).nextLine());
                    System.out.println("Enter email");
                    str[4]=(new Scanner(System.in).nextLine());
//                    r.addContact(str[0], str[1], str[2], str[3], str[4]);
                    break;
                case 2:
                    System.out.println("id\tfirstName\tlastName\tlastName\tmiddleName\thomePhone\temail");
                    System.out.println(r.showContactList());
                    break;
                case 3:
                    System.out.println("Enter id");
                    try
                    {
                        r.delContact(new Scanner(System.in).nextInt());
                        break;
                    }
                    catch(Exception ex)
                    {
                        System.out.println("Mistake id");
                        break;
                    }
                case 4:
                    System.out.println("Enter id");
                    //r.cahngeContact(new Scanner(System.in).nextInt());
                    break;
                case 11:
                    System.out.println("Enter title");
                    String s = new Scanner(System.in).nextLine();
                    System.out.println("Enter date");
                    SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
                    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                    //t.addTask(0,sdf.parse(br.readLine()),s);
                    t.showTaskList();
                    break;
                case 22:
                    System.out.println("id\tbeginDate\ttitle\ttype");
                    System.out.println(t.showTaskList());
                    break;
                case 33:
                    System.out.println("Enter id");
                    t.delTask(new Scanner(System.in).nextInt());
                    break;
                case 44:
                    System.out.println("Enter id");
                    //t.cahngeTask(new Scanner(System.in).nextInt());
                    break;
                    
                default:
                    System.err.print("Good bye!");
                    System.exit(0);
            }
        }
    }
    
    
}
